//
//  AppDelegate+ZBAddNetwork.m
//  ZBMainFramework
//
//  Created by apple on 2018/10/23.
//  Copyright © 2018年 apple. All rights reserved.
//

#import "AppDelegate+ZBAddNetwork.h"


@implementation AppDelegate (ZBAddNetwork)
/**
 加载App的版本
 */
- (void)loadAppVersion
{
    
}

//弹框
- (void)checkVersionAlertViewWithMessage:(NSString *)message link:(NSString *)link isForce:(BOOL)isForce
{
    WS(weakSelf);
    UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"温馨提示" message:message preferredStyle:UIAlertControllerStyleAlert];
    if(isForce){
        UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"Upgrade immediately" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
            if([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:link]])
                [[UIApplication sharedApplication] openURL:[NSURL URLWithString:link]];
            [[weakSelf getCurrentViewController] dismissViewControllerAnimated:YES completion:nil];
        }];
        [alertVC addAction:action1];
    }else{
        UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"Cancle" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
            [[weakSelf getCurrentViewController] dismissViewControllerAnimated:YES completion:nil];
        }];
        UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            if([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:link]])
                [[UIApplication sharedApplication] openURL:[NSURL URLWithString:link]];
            [[weakSelf getCurrentViewController] dismissViewControllerAnimated:YES completion:nil];
            
        }];
        [alertVC addAction:action1];
        [alertVC addAction:action2];
    }
    
    [[self getCurrentViewController] presentViewController:alertVC animated:YES completion:nil];
}
@end
